﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService
Imports System.IO
Partial Class Control_QuanLyMaSoThue_Create
    Inherits System.Web.UI.UserControl
    Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
#Region "Sub and Function "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

            Dim script As ScriptManager = ScriptManager.GetCurrent(Me.Page)
            If Not script Is Nothing AndAlso script.IsInAsyncPostBack Then
                ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "jqueryEnable", "ajaxJquery()", True)
            Else
                Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "jqueryEnable", String.Concat("Sys.Application.add_load(function(){", "ajaxJquery()", "});"), True)
            End If

        End If
    End Sub
    Protected Function Save() As Boolean
        Using data As New VSEntities
            Dim p As New VSModel.NguoiNopThue
            Try
                p.MaCQT = txtMaCQT.Text.Trim()
                p.TenCQT = txtTenCQT.Text.Trim()
                p.SoNguoiNopThue = txtSoNguoiNopThue.Text.Trim()
                p.MaSoThue = txtMaSoThue.Text.Trim()
                p.TenNguoiNopThue = txtTenNguoiNopThue.Text.Trim()
                p.MaNganhChinh = txtMaNganhChinh.Text.Trim()
                p.TenNganhChinh = txtTenNganhChinh.Text.Trim()
                p.SoNha = txtSoNha.Text.Trim()
                p.MaPhuongXa = txtMaPhuongXa.Text.Trim()
                p.TenPhuongXa = txtTenPhuongXa.Text.Trim()
                p.MaHuyen = txtMaHuyen.Text.Trim()
                p.Huyen = txtHuyen.Text.Trim()
                p.MaTinh = txtMaTinh.Text.Trim()
                p.TenTinh = txtTenTinh.Text.Trim()
                p.TongSoLaoDong = txtTongSoLaoDong.Text.Trim()
                p.NganhNghe = txtNganhNghe.Text.Trim()
                p.TenGiamDoc = txtTenGiamDoc.Text.Trim()
                p.DienThoaiGiamDoc = txtDienThoaiGiamDoc.Text.Trim()
                p.SoGiayTo = txtSoGiayTo.Text.Trim()
                p.NgayCap = txtNgayCap.Text.Trim()
                p.LoaiGiayTo = txtLoaiGiayTo.Text.Trim()
                p.SoGCN = txtSoGCN.Text.Trim()
                p.NgayCapGCN = txtNgayCapGCN.Text.Trim()
                p.CMND = txtCMND.Text.Trim()
                p.TenChuong = txtTenChuong.Text.Trim()
                p.TenKhoan = txtTenKhoan.Text.Trim()
                p.LoaiNguoiNopThue = txtLoaiNguoiNopThue.Text.Trim()
                p.MaTrangThaiDKTCaNhan = txtMaTrangThaiDKTCaNhan.Text.Trim()
                p.TrangThaiDKTCaNhan = txtTrangThaiDKTCaNhan.Text.Trim()
                p.MaTrangThaiDKTToChuc = txtMaTrangThaiDKTToChuc.Text.Trim()
                p.TrangThaiDKTToChuc = txtTrangThaiDKTToChuc.Text.Trim()
                p.NgayNhanToKhai = txtNgayNhanToKhai.Text.Trim()
                p.LoaiHinhKinhTe = txtLoaiHinhKinhTe.Text.Trim()
                p.TamNghiTuNgay = txtTamNghiTuNgay.Text.Trim()
                p.TamNghiDenNgay = txtTamNghiDenNgay.Text.Trim()
                p.LyDoTamNghi = txtLyDoTamNghi.Text.Trim()
                p.LyDoDongMSTCaNhan = txtLyDoDongMSTCaNhan.Text.Trim()
                p.NgayDongTrangThaiCaNhan = txtNgayDongTrangThaiCaNhan.Text.Trim()
                p.LyDoDongMSTToChuc = txtLyDoDongMSTToChuc.Text.Trim()
                p.NgayDongTrangThaiToChuc = txtNgayDongTrangThaiToChuc.Text.Trim()
                p.QuocTich = txtQuocTich.Text.Trim()
                p.NgaySinh = txtNgaySinh.Text.Trim()
                p.VonKinhDoanh = txtVonKinhDoanh.Text.Trim()
                p.NguonVonNSNN = txtNguonVonNSNN.Text.Trim()
                p.NguonVonNuocNgoai = txtNguonVonNuocNgoai.Text.Trim()
                p.NguonVonKhac = txtNguonVonKhac.Text.Trim()
                p.NgayBatDauKinhDoanh = txtNgayBatDauKinhDoanh.Text.Trim()
                p.DienThoaiBan = txtDienThoaiBan.Text.Trim()
                data.NguoiNopThues.AddObject(p)
                data.SaveChanges()
                'Insert_App_Log("Insert  NguoiNopThue:" & txtTitle.Text.Trim & "", Function_Name.NguoiNopThue, Audit_Type.Create, Request.ServerVariables("REMOTE_ADDR"), Session("UserName"))
                Return True
            Catch ex As Exception
                log4net.Config.XmlConfigurator.Configure()
                log.Error("Error error " & AddTabSpace(1) & Session("Username") & AddTabSpace(1) & "IP:" & GetIPAddress(), ex)
                Return False
            End Try
        End Using
    End Function
    Protected Sub ResetControl()
        txtMacqt.Text = ""
        txtTencqt.Text = ""
        txtSonguoinopthue.Text = ""
        txtMasothue.Text = ""
        txtTennguoinopthue.Text = ""
        txtManganhchinh.Text = ""
        txtTennganhchinh.Text = ""
        txtSonha.Text = ""
        txtMaphuongxa.Text = ""
        txtTenphuongxa.Text = ""
        txtMahuyen.Text = ""
        txtHuyen.Text = ""
        txtMatinh.Text = ""
        txtTentinh.Text = ""
        txtTongsolaodong.Text = ""
        txtNganhnghe.Text = ""
        txtTengiamdoc.Text = ""
        txtDienthoaigiamdoc.Text = ""
        txtSogiayto.Text = ""
        txtNgaycap.Text = ""
        txtLoaigiayto.Text = ""
        txtSogcn.Text = ""
        txtNgaycapgcn.Text = ""
        txtCmnd.Text = ""
        txtTenchuong.Text = ""
        txtTenkhoan.Text = ""
        txtLoainguoinopthue.Text = ""
        txtMatrangthaidktcanhan.Text = ""
        txtTrangthaidktcanhan.Text = ""
        txtMatrangthaidkttochuc.Text = ""
        txtTrangthaidkttochuc.Text = ""
        txtNgaynhantokhai.Text = ""
        txtLoaihinhkinhte.Text = ""
        txtTamnghitungay.Text = ""
        txtTamnghidenngay.Text = ""
        txtLydotamnghi.Text = ""
        txtLydodongmstcanhan.Text = ""
        txtNgaydongtrangthaicanhan.Text = ""
        txtLydodongmsttochuc.Text = ""
        txtNgaydongtrangthaitochuc.Text = ""
        txtQuoctich.Text = ""
        txtNgaysinh.Text = ""
        txtVonkinhdoanh.Text = ""
        txtNguonvonnsnn.Text = ""
        txtNguonvonnuocngoai.Text = ""
        txtNguonvonkhac.Text = ""
        txtNgaybatdaukinhdoanh.Text = ""
        txtDienthoaiban.Text = ""
    End Sub
#End Region
#Region "Event for control "
    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If Save() Then
            Excute_Javascript("Alertbox('Cập nhật dữ liệu thành công.');window.location ='../../Page/NguoiNopThue/List.aspx';", Me.Page, True)
        Else
            Excute_Javascript("Alertbox('Cập nhật thất bại.');", Me.Page, True)
        End If
    End Sub
    Protected Sub btnSaveAndNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveAndNew.Click
        If Save() Then
            Excute_Javascript("Alertbox('Cập nhật dữ liệu thành công.');", Me.Page, True)
            ResetControl()
        Else
            Excute_Javascript("Alertbox('Cập nhật thất bại.');", Me.Page, True)
        End If
    End Sub
    Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        ResetControl()
    End Sub
    Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnBack.Click
        Response.Redirect("List.aspx")
    End Sub
#End Region
End Class
